:root {
  font-family: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  line-height: 1.5;
  font-weight: 400;
  color-scheme: light;
  --gradient-start: #fef5ff;
  --gradient-mid: #f7edff;
  --gradient-end: #e7f4ff;
  --aurora-rose: rgba(255, 182, 203, 0.35);
  --aurora-mint: rgba(174, 236, 235, 0.4);
  --window-bg: rgba(255, 255, 255, 0.78);
  --window-border: rgba(236, 239, 255, 0.6);
  --surface-bg: rgba(255, 255, 255, 0.68);
  --surface-border: rgba(209, 214, 238, 0.5);
  --text-primary: #221b3a;
  --text-secondary: rgba(60, 52, 98, 0.65);
  --pill-text: #ffffff;
  --pill-text-alt: #221b3a;
  --accent: #f98ca7;
  --accent-strong: #f76f92;
  --accent-soft: rgba(249, 140, 167, 0.18);
  --accent-glow: rgba(249, 140, 167, 0.32);
  --focus-ring: rgba(249, 140, 167, 0.35);
  --shadow-soft: 0 18px 44px rgba(40, 27, 70, 0.14);
  --shadow-card: 0 12px 28px rgba(44, 29, 70, 0.12);
  --shell-pad-x: clamp(16px, 6vw, 56px);
  --shell-pad-y: clamp(16px, 5vh, 40px);
  --window-radius: clamp(18px, 2.5vw, 30px);
  --window-min-width: 320px;
  --window-min-height: 360px;
}

body[data-theme="dark"] {
  color-scheme: dark;
  --gradient-start: #151225;
  --gradient-mid: #1e1634;
  --gradient-end: #10121c;
  --aurora-rose: rgba(249, 140, 167, 0.38);
  --aurora-mint: rgba(104, 180, 206, 0.42);
  --window-bg: rgba(24, 20, 33, 0.78);
  --window-border: rgba(88, 74, 123, 0.35);
  --surface-bg: rgba(32, 26, 46, 0.7);
  --surface-border: rgba(122, 102, 170, 0.28);
  --text-primary: #f6f4ff;
  --text-secondary: rgba(222, 219, 240, 0.64);
  --pill-text: #161020;
  --pill-text-alt: #f6f4ff;
  --accent: #f78cab;
  --accent-strong: #f56a91;
  --accent-soft: rgba(247, 140, 171, 0.25);
  --accent-glow: rgba(247, 140, 171, 0.4);
  --focus-ring: rgba(247, 140, 171, 0.35);
  --shadow-soft: 0 18px 44px rgba(0, 0, 0, 0.45);
  --shadow-card: 0 12px 32px rgba(8, 6, 14, 0.32);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body,
#root {
  height: 100%;
}

body {
  position: relative;
  background: radial-gradient(120% 120% at 15% 20%, var(--gradient-start), var(--gradient-mid) 55%, var(--gradient-end));
  color: var(--text-primary);
  overflow: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  pointer-events: none;
  z-index: -2;
  filter: blur(0);
  transition: background 0.4s ease;
}

body::before {
  top: -120px;
  left: -80px;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.92), var(--aurora-rose));
  opacity: 0.9;
}

body::after {
  bottom: -160px;
  right: -120px;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  background: radial-gradient(circle at 65% 65%, rgba(255, 255, 255, 0.78), var(--aurora-mint));
  opacity: 0.75;
}

body[data-theme="dark"]::before {
  background: radial-gradient(circle at 30% 30%, rgba(247, 140, 171, 0.6), rgba(118, 86, 180, 0.4));
  opacity: 0.8;
}

body[data-theme="dark"]::after {
  background: radial-gradient(circle at 60% 60%, rgba(118, 86, 180, 0.45), rgba(70, 120, 200, 0.35));
  opacity: 0.7;
}

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-thumb {
  background-color: rgba(120, 120, 130, 0.35);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background-color: rgba(120, 120, 130, 0.55);
}

.app-shell {
  min-height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: var(--shell-pad-y) var(--shell-pad-x);
  overflow-y: auto;
}

.window {
  width: 100%;
  max-width: calc(100vw - 2 * var(--shell-pad-x));
  min-width: var(--window-min-width);
  height: max(var(--window-min-height), calc(100vh - 2 * var(--shell-pad-y)));
  min-height: var(--window-min-height);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  border-radius: var(--window-radius);
  border: 1px solid var(--window-border);
  background: var(--window-bg);
  -webkit-backdrop-filter: blur(28px) saturate(140%);
  backdrop-filter: blur(28px) saturate(140%);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.window__header {
  padding: 20px 24px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand__icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.85), rgba(249, 140, 167, 0.35));
  border: 1px solid rgba(255, 255, 255, 0.65);
  color: var(--accent-strong);
  box-shadow: 0 12px 28px var(--accent-soft), inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.brand__icon .svg-icon {
  width: 24px;
  height: 24px;
}

.brand__text h1 {
  font-size: 22px;
  font-weight: 640;
  letter-spacing: -0.015em;
}

.brand__text span {
  font-size: 12px;
  color: var(--text-secondary);
}

.utility {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search input {
  flex: 1;
  width: 100%;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.42));
  color: var(--text-primary);
  font-size: 13px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search input::placeholder {
  color: rgba(120, 120, 130, 0.65);
}

.search input:focus {
  outline: none;
  border-color: rgba(243, 109, 63, 0.55);
  box-shadow: 0 0 0 3px rgba(243, 109, 63, 0.15);
}

.utility__actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.btn {
  flex: 1;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0.42));
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.015em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(15, 19, 34, 0.12);
}

.btn:active {
  transform: translateY(0);
}

.btn.btn--ghost {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0.2));
}

.btn.btn--icon {
  flex: 0 0 auto;
  padding-inline: 12px;
}

.btn.btn--icon .svg-icon {
  width: 16px;
  height: 16px;
}

.btn.btn--danger {
  background: linear-gradient(135deg, rgba(248, 92, 119, 0.92), rgba(238, 73, 103, 0.78));
  color: #ffffff;
  border-color: rgba(238, 73, 103, 0.9);
  box-shadow: 0 12px 26px rgba(238, 73, 103, 0.38);
}

.btn.btn--danger:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 28px rgba(238, 73, 103, 0.45);
}

.btn.btn--danger:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  box-shadow: none;
}

.favorites-toggle {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.26);
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
  color: var(--text-secondary);
}

.favorites-toggle:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.5);
  color: var(--text-primary);
}

.favorites-toggle.is-active {
  color: var(--accent);
  border-color: rgba(243, 109, 63, 0.5);
  background: rgba(243, 109, 63, 0.12);
}

.status-banner {
  margin-top: 2px;
  padding: 6px 10px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 11.5px;
  text-align: center;
}

.history {
  flex: 1;
  min-height: 0;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.history__fallback {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text-secondary);
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid rgba(240, 240, 255, 0.35);
  border-top-color: var(--accent);
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.3);
}

.history__list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1 1 auto;
  overflow-y: auto;
  padding-right: 4px;
}

.history-card {
  position: relative;
  border-radius: 16px;
  border: 1px solid var(--surface-border);
  background: var(--surface-bg);
  padding: 14px 16px;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-card);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  cursor: pointer;
}

.history-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 28px rgba(16, 18, 26, 0.16);
}

.history-card--favorite {
  border-color: var(--accent);
  box-shadow: 0 18px 38px var(--accent-glow);
}

.history-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  gap: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--accent-soft);
  color: var(--accent);
}

.pill--text {
  background: rgba(96, 204, 150, 0.18);
  color: #1b9a63;
}

.pill--file {
  background: rgba(255, 221, 142, 0.2);
  color: #c57e00;
}

.pill--image {
  background: rgba(255, 173, 173, 0.18);
  color: #d75b5a;
}

.history-card__actions {
  display: flex;
  gap: 6px;
}

.icon-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.24);
  transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
  color: var(--text-secondary);
}

body[data-theme="dark"] .icon-btn {
  background: rgba(255, 255, 255, 0.14);
}

.icon-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.5);
  color: var(--text-primary);
}

.icon-btn.is-active {
  color: var(--accent);
  border-color: rgba(243, 109, 63, 0.45);
  background: rgba(243, 109, 63, 0.12);
}

.svg-icon {
  width: 18px;
  height: 18px;
}

.history-card__preview {
  margin: 0;
  font-family: "SF Mono", "Menlo", "Roboto Mono", monospace;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: clamp(160px, 50vh, 560px);
  overflow-y: auto;
  padding-right: 2px;
}

.history-card__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  gap: 10px;
}

.history-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag-chip {
  padding: 2px 8px;
  font-size: 10.5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.3);
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.tag-chip:hover {
  color: var(--text-primary);
  border-color: rgba(243, 109, 63, 0.4);
  background: rgba(243, 109, 63, 0.12);
}

.history-card__time {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.tag-editor {
  margin-top: 10px;
  padding: 9px;
  border-radius: 12px;
  border: 1px dashed rgba(243, 109, 63, 0.4);
  background: rgba(243, 109, 63, 0.08);
}

.tag-editor input {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}


.settings-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: rgba(14, 10, 28, 0.28);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  z-index: 10;
  padding: 48px 24px;
  overflow-y: auto;
}

.settings-panel {
  width: min(420px, 92%);
  max-width: 520px;
  max-height: calc(100vh - 96px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 24px 20px;
  border-radius: 20px;
  border: 1px solid var(--surface-border);
  background: var(--surface-bg);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  backdrop-filter: blur(22px) saturate(160%);
  box-shadow: var(--shadow-card);
  overflow-y: auto;
}

.settings-panel__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.settings-panel__header h2 {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.settings-panel__header p {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.close-btn {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.35);
}

.close-btn:hover {
  color: var(--text-primary);
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.6));
  box-shadow: 0 10px 26px rgba(41, 32, 66, 0.08);
}

body[data-theme="dark"] .settings-group {
  border-color: rgba(122, 102, 170, 0.38);
  background: linear-gradient(140deg, rgba(40, 32, 58, 0.85), rgba(40, 32, 58, 0.65));
  box-shadow: 0 16px 32px rgba(10, 6, 16, 0.4);
}

.settings-group--danger {
  border-color: rgba(238, 73, 103, 0.35);
}

.settings-group__heading {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-group__heading h3 {
  font-size: 14px;
  font-weight: 620;
  color: var(--text-primary);
}

.settings-group__heading span {
  font-size: 12px;
  color: var(--text-secondary);
}

.theme-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.6);
  color: var(--text-secondary);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease,
    color 0.2s ease, box-shadow 0.2s ease;
}

.theme-option:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.7);
  color: var(--text-primary);
}

.theme-option.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  box-shadow: 0 12px 24px var(--accent-glow);
}

.theme-option .svg-icon {
  width: 18px;
  height: 18px;
}

.theme-option__icon {
  font-size: 16px;
}

.theme-option__label {
  font-size: 12.5px;
  font-weight: 600;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  font-size: 13px;
  color: var(--text-secondary);
}

.switch {
  width: 46px;
  height: 26px;
  border-radius: 999px;
  border: none;
  background: rgba(34, 27, 60, 0.22);
  padding: 3px;
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

body[data-theme="dark"] .switch {
  background: rgba(122, 102, 170, 0.35);
}

.switch .switch__thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  transform: translateX(0);
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 6px 12px rgba(20, 16, 40, 0.2);
}

.switch.is-on {
  background: var(--accent);
  box-shadow: 0 8px 16px var(--accent-glow);
}

.switch.is-on .switch__thumb {
  transform: translateX(18px);
}

.switch:disabled {
  opacity: 0.6;
  cursor: progress;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-row input {
  flex: 1;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.65);
  color: var(--text-primary);
  font-size: 13px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

body[data-theme="dark"] .settings-row input {
  border-color: rgba(122, 102, 170, 0.45);
  background: rgba(40, 32, 58, 0.65);
}

.settings-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.settings-hint {
  font-size: 11.5px;
  color: var(--text-secondary);
}

.settings-panel__footer {
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 640px) {
  :root {
    --shell-pad-x: 18px;
    --shell-pad-y: 18px;
    --window-radius: 14px;
    --window-min-width: 280px;
    --window-min-height: 320px;
  }

  .app-shell {
    align-items: stretch;
    padding: var(--shell-pad-y) var(--shell-pad-x);
  }

  .window {
    width: calc(100vw - 2 * var(--shell-pad-x));
    height: calc(100vh - 2 * var(--shell-pad-y));
    min-height: calc(100vh - 2 * var(--shell-pad-y));
    border-radius: var(--window-radius);
  }

  .window__header {
    padding: 18px 16px 12px;
    gap: 10px;
  }

  .brand__text h1 {
    font-size: 20px;
  }

  .history {
    padding: 16px 14px;
  }

  .history-card {
    padding: 13px 14px;
  }

  .settings-overlay {
    padding: 32px 16px;
  }

  .settings-panel {
    width: 100%;
    max-height: calc(100vh - 64px);
    padding: 20px 18px;
    border-radius: 18px;
  }

}

@media (max-height: 720px) {
  .settings-overlay {
    padding: 32px 16px;
  }

  .settings-panel {
    max-height: calc(100vh - 64px);
  }
}
